#!/bin/bash

echo "🔧 修复memento-ui依赖问题..."

# 进入父项目目录
cd /Users/lilanfeng/CPP_CODE/memento/memento-parent

echo "🧹 1. 清理Maven缓存..."
# 清理本地仓库中的缓存
rm -rf ~/.m2/repository/com/example/memento-model
rm -rf ~/.m2/repository/org/jetbrains/compose

echo "📦 2. 编译memento-model模块..."
mvn clean compile -pl memento-model

if [ $? -eq 0 ]; then
    echo "✅ memento-model编译成功"
    
    echo "📦 3. 安装memento-model到本地仓库..."
    mvn install -pl memento-model -DskipTests
    
    if [ $? -eq 0 ]; then
        echo "✅ memento-model安装成功"
        
        echo "📦 4. 强制更新依赖并编译memento-ui模块..."
        mvn clean compile -pl memento-ui -U
        
        if [ $? -eq 0 ]; then
            echo "🎉 memento-ui编译成功！"
        else
            echo "❌ memento-ui编译失败"
            exit 1
        fi
    else
        echo "❌ memento-model安装失败"
        exit 1
    fi
else
    echo "❌ memento-model编译失败"
    exit 1
fi

echo "🎉 修复完成！"